/**************************
This function save all the histograms to a file.


*****************************/

using namespace std;

void print_histo2d(ofstream *outhisto, gsl_histogram2d * histo){


  //write
  long buffl=0;
  double buffd=0;
  
  //size
  buffl=histo->nx;
  outhisto->write((char *)(&buffl),sizeof(buffl));

  buffl=histo->ny;
  outhisto->write((char *)(&buffl),sizeof(buffl));


  //write xrange
  for(int i=0;i<=(int)histo->nx;i++){
    buffd=histo->xrange[i];
    outhisto->write((char *)(&buffd),sizeof(buffd));
  }

  
  
  for(int i=0;i<=(int)histo->ny;i++){
    buffd=histo->yrange[i];
    outhisto->write((char *)(&buffd),sizeof(buffd));
  }


  
  //write bin
  for(int i=0;i<(int)histo->nx;i++){
    for(int j=0;j<(int)histo->ny;j++){
      buffd=gsl_histogram2d_get(histo,i,j);
      outhisto->write((char *)(&buffd),sizeof(buffd));
    }
  }
 
  
  return;
}
